package com.corpgovernment.organization.util;

import com.corpgovernment.common.base.CommonException;
import com.corpgovernment.common.common.CorpBusinessException;
import com.corpgovernment.organization.constant.OrganizationResponseCodeEnum;
import com.ctrip.corp.obt.generic.utils.StringUtils;
import com.ctrip.corp.obt.generic.utils.CollectionUtils;
import com.ctrip.corp.obt.generic.utils.StringUtils;

import java.util.Collection;

public class PreCheckUtil {

    public static void checkNotNull(Object object, String msg) {
        if (object == null) {
            throw new CorpBusinessException(OrganizationResponseCodeEnum.CUSTOM_CONTENT, msg);
        }
    }

    public static void checkNotEmpty(String str, String msg) {
        if (StringUtils.isBlank(str)) {
            throw new CorpBusinessException(OrganizationResponseCodeEnum.CUSTOM_CONTENT, msg);
        }
    }

    public static void checkNotEmpty(Collection collection, String msg) {
        if (CollectionUtils.isEmpty(collection)) {
            throw new CorpBusinessException(OrganizationResponseCodeEnum.CUSTOM_CONTENT, msg);
        }
    }

    public static void checkArgument(boolean b, String msg) {
        if (!b) {
            throw new CorpBusinessException(OrganizationResponseCodeEnum.CUSTOM_CONTENT, msg);
        }
    }
}